import request from '@/utils/request';

//新增
export async function addSpareInfo(params: any) {
  return request('/api/device/addSpareInfo', {
    method: 'POST',
    data: params,
  });
}
//删除
export async function delSpareInfo(params: any) {
  return request('/api/device/delSpareInfo', {
    method: 'POST',
    data: params,
  });
}
//编辑
export async function updateSpareInfo(params: any) {
  return request('/api/device/updateSpareInfo', {
    method: 'POST',
    data: params,
  });
}
//干嘛的 查询？
export async function getSpareInfoByPage(params: any) {
  return request('/api/device/getSpareInfoByPage', {
    method: 'POST',
    data: params,
  });
}
export async function exportSpareInfo(params: any) {
  return request('/api/device/exportSpareInfo', {
    method: 'POST',
    data: params,
    responseType: 'blob',
  });
}
//spareFile
export async function addSpareFile(params: any) {
  return request('/api/device/addSpareFile', {
    method: 'POST',
    data: params,
  });
}

export async function delSpareFile(params: any) {
  return request('/api/device/delSpareFile', {
    method: 'POST',
    data: params,
  });
}

export async function exportSpareFile(params: any) {
  return request('/api/device/exportSpareFile', {
    method: 'POST',
    data: params,
    responseType: 'blob',
  });
}

export async function getSpareFileByPage(params: any) {
  return request('/api/device/getSpareFileByPage', {
    method: 'POST',
    data: params,
  });
}

export async function updateSpareFile(params: any) {
  return request('/api/device/updateSpareFile', {
    method: 'POST',
    data: params,
  });
}

export async function uploadSpareFile(para: any) {
  return request('/api/device/uploadSpareFile', {
    method: 'POST',
    requestType: 'form',
    data: para.file,
    headers: {
      'Content-Type': 'multipart/form-data; boundary=----WebKitFormBoundaryX72QZDdfwlF5U73J',
    },
    params: {
      spareinfoId: para.spareinfoId,
      fileName: para.fileName,
    },
  });
}
export default {
  addSpareInfo,
  delSpareInfo,
  updateSpareInfo,
  getSpareInfoByPage,
  exportSpareInfo,
  addSpareFile,
  delSpareFile,
  exportSpareFile,
  getSpareFileByPage,
  updateSpareFile,
  uploadSpareFile,
};
